package com.shaolei.client_thread;
import java.io.IOException;
import java.io.InputStream;

import com.shaolei.basic.BASIC_QQ;

public class Client_in extends BASIC_QQ implements Runnable {
	
	private static boolean status=true;
	private InputStream in;
	public Client_in(){
	}
	public Client_in(InputStream in){
		this.in=in;
	}
	public void run(){
		//read message
		while (status){
			byte [] receiveBuf=new byte[this.get_BUFSIZE()];
			int length=0;
			try {
				length = in.read(receiveBuf,0,this.get_BUFSIZE());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				break;
			}
			if (length<0){
				status=false;
				break;
			} 
			String receive= new String(receiveBuf,0,length);
			receive=this.unpack(receive);//unpack package
			System.out.println(receive);
		}
	}
	public boolean get_status(){
		return status;
	}
}
